package com.xyc.petmallsystem.controller;

import com.xyc.petmallsystem.repository.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Joel
 * @date 2021/12/9
 *
 * 数据汇总
 */

@RestController
@RequestMapping("/gather")
public class GatherController {

    @Autowired
    UserRepository userRepository;

    @Autowired
    CouponRepository couponRepository;

    @Autowired
    CarsRepository carsRepository;

    @Autowired
    CatRepository catRepository;

    @Autowired
    PersonalRepository personalRepository;

    /*
    获取用户总数
     */
    @GetMapping("/getUserCount")
    public Integer getUserCount() {
        return userRepository.getUserCount();
    }

    /*
    获取优惠码数量
     */
    @GetMapping("/getCouponCount")
    public Integer getCouponCount() {
        return couponRepository.getCouponCount();
    }

    /*
    获取购物车数量
     */
    @GetMapping("/getCarsCount")
    public Integer getCarsCount() {
        return carsRepository.getCarsCount();
    }

    /*
    获取猫咪的数量
     */
    @GetMapping("/getCatCount")
    public Integer getCatCount() {
        return catRepository.getCatCount();
    }

    /*
    获取男性用户的数量
     */
    @GetMapping("/userGender0")
    public Integer getUserGender0() {
        System.out.println("男性用户：" + personalRepository.getUserGender0());
        return personalRepository.getUserGender0();
    }

    /*
    获取女性用户的数量
     */
    @GetMapping("/userGender1")
    public Integer getUserGender1() {
        System.out.println("女性用户：" + personalRepository.getUserGender1());
        return personalRepository.getUserGender1();
    }
}
